
#include <iostream>
#include <typeinfo>
using namespace std;

int Max( int x, int y ) {
	return x > y ? x : y;
}

int main( void ) {
	int a = 10, b = 20;
	cout << Max( a, b ) << endl;

	auto f = []( int x, int y ) -> int { return x > y ? x : y; };
	// According to your lambda expression.
	// 	1. Create a class
	// 	2. Define a operator function in the class
	// 	3. Return a anonymous object
	/*
	class  Z4mainEUliiE_ {
	public:
		int operator()( int x, int y ){
			return x > y ? x : y;
		}
	};
	auto f = Z4mainEUliiE_{};
	*/
	cout << f( a, b ) << endl;	// f.operator()( a, b );
	cout << "f : " << typeid(f).name() << endl;
	
	cout << []( int x, int y ) { return x + y; }(a, b) << endl;
	/*
	class X {
	public:
		auto operator()( int x, int y )->decltype(x+y){
			ruturn x + y;
		}
	};
	cout << X{}.operator()(a,b) << endl;
	*/

	// If lambda don't have a return and return type, then the type of return is void.
	[]( int x, int y ) { cout << x << ' ' << y << endl; }( a, b );
	/*
	class xx {
	public:
		void opterator()( int x, int y ) {
			cout << x << ' ' << y << endl;
		}
	};
	xx{}(a,b);
	*/

	[]{ cout << "hello world" << endl; }();
	/*
	class xxxx {
	public:
		void opterator()( void ) {
			cout << x << ' ' << y << endl;
		}
	};
	xxxx{};
	*/

	return 0;
}

